package com.cybertron.lockdown.spider;

import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.processor.PageProcessor;

/**
 * Created by xiezhouyan on 15-1-10.
 */
public class LockdownPageProcessor implements PageProcessor {

    private final SiteManager siteManager;

    public LockdownPageProcessor(SiteManager siteManager) {
        this.siteManager = siteManager;
    }

    @Override
    public void process(Page page) {
        siteManager.getSite(page.getRequest().getUrl()).listener().pageProcess(page);
    }

    @Override
    public us.codecraft.webmagic.Site getSite() {
        return us.codecraft.webmagic.Site.me().setRetryTimes(3).setSleepTime(1000);
    }
}
